package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"

	"github.com/tendermint/tendermint/types"
)

func main() {
	url := fmt.Sprintf("http://10.77.110.184:20001/block_pack?height=%d", 3)

	// 发送 GET 请求
	resp, err := http.Get(url)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	// 读取响应
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	var blockPack BlockPack
	// 解析 JSON 响应
	err = json.Unmarshal(body, &blockPack)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%v", blockPack)

}

type Block struct {
	Header           types.Header       `protobuf:"bytes,1,opt,name=header,proto3" json:"header"`
	Data             types.Data         `protobuf:"bytes,2,opt,name=data,proto3" json:"data"`
	Evidence         types.EvidenceList `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence"`
	LastCommit       *types.Commit      `protobuf:"bytes,4,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"`
	LastChainedId    []*types.BlockID   `protobuf:"bytes,5,rep,name=last_chained_id,json=lastChainedId,proto3" json:"last_chained_id,omitempty"`
	LastCommitStatus [][]byte           `protobuf:"bytes,6,rep,name=last_commit_status,json=lastCommitStatus,proto3" json:"last_commit_status,omitempty"`
}
type BlockPack struct {
	Chain_id        string             `json:"chain_id"`
	ProposalBlock   *Block             `json:"pb"`
	DeliverResponse []byte             `json:"dr"`
	ValidatorUpdate []*types.Validator `json:"vu"`
}
